// src/main/java/com/yourcompany/captchademo/controller/CaptchaController.java
package com.study.mirrorforest.main.model.auth.controller;

import com.study.mirrorforest.main.common.response.R;
import com.study.mirrorforest.main.model.auth.dto.CaptchaVO;
import com.study.mirrorforest.main.model.auth.dto.VerifyCaptchaDTO;
import com.study.mirrorforest.main.model.auth.service.CaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/auth")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @GetMapping("/captcha")
    public R<CaptchaVO> getCaptcha() {
        System.out.println("[CaptchaController] getCaptcha called");
        return captchaService.generateCaptcha();
    }

    @PostMapping("/captcha/verify")
    public R<String> verifyCaptcha(@RequestBody VerifyCaptchaDTO verifyCaptchaDTO) {
        System.out.println("[CaptchaController] verifyCaptcha called with: " + verifyCaptchaDTO);
        return captchaService.verifyCaptcha(verifyCaptchaDTO);
    }
}